var ws, aid, hid, dname, djob, offices;
document.addEventListener('plusready', function(){
	ws = plus.webview.currentWebview();
	aid = ws.aid;	//医生id
	hid = ws.hid;	//医院id
	console.log(aid+" "+hid);
	$.ajax({
		type:"get",
		url:apiRoot+"?m=home&c=studio&a=allPrice&did="+aid,
		dataType :'json',
		success :function(data){
//			console.log(JSON.stringify(data));
			var dt = data.zixun;
			if(dt[0]){
				$('.textbox').text(dt[0]);
				tcall = dt[0];
			}else{
				$('.tex').text('期待开通');
				$('.pictext').removeClass('color-yellowish');
				$('.pictext').addClass('color-ddd');
				$('#text').removeAttr("id"); 
			}
			if(dt[1]){
				$('.telcall').text(dt[1]);
				pcall = dt[1];
			}else{
				$('.pho').text('期待开通');
				$('.tel').removeClass('color-yellowish');
				$('.tel').addClass('color-ddd');
				$('#phone').removeAttr("id"); 
			}
			if(dt[2]){
				videoprice = dt[2];
				$('.video').text(dt[2]);
			}else{
				$('.video').text('期待开通');
				$('.shipin').removeClass('color-yellowish');
				$('.shipin').addClass('color-ddd');
				$('#video').removeAttr("id"); 
			}
			plus.nativeUI.closeWaiting();
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
	$.ajax({
		type:"get",
		url:apiRoot+"/home/bespoke/doctorinfo",
		data :{aid:aid},
		dataType :'json',
		success :function(data){
//			console.log(JSON.stringify(data));
			dname = data.title;
			djob = data.job;
			offices = data.offices;
			$('.name').text(data.title);
			$('.job').text(data.job);
			$('.studio').text(data.offices);//所属科室
			$('.avatar').attr('src', getAvatar(data.avatar));
			$('.doctor-text').html(data.info);
		},
		error :function(e){
			console.log(JSON.stringify(e));
			errortoast();
		}
	});
	//点击按钮
	$('.mui-bar-footer button').on('tap', function(){
		switch($(this).index()){
			case 0:		//患者评价
			bespoke('yuyue-huanz.html', {aid :aid});
			break;
			case 1:		//立即预约——>跳转到预约时间
			bespoke('yuyue-time.html', {hid:hid, did:aid, dname:dname, djob:djob, offices:offices});
			break;
		}
	})

},false)
//跳转
function bespoke(url, obj){
	goNewPage(url, obj);
}